<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="../org/angular.min.js"></script>
    <script src="../org/jquery.min.js"></script>
</head>
<body>

<div ng-app="hd">
    <div ng-controller="ctrl1">
{{data}}
    </div>
    <div ng-controller="ctrl2">
        {{data}}
    </div>

</div>
<script>
    var m = angular.module('hd', []);



    m.controller('ctrl1', ['$scope', '$cacheFactory', function ($scope, $cacheFactory) {

        var obj = $cacheFactory('hdphp'); //创建缓存对象
        //出入数据
        obj.put('web', {name: '后盾人', url: 'houdunren.com'});
        obj.put('user', {name: '向军', mail: '1549645351@qq.com'});
        $scope.data = obj.get('web').url;

        //删除数据
        //obj.remove('web');
        //obj.removeAll();
        //obj.destroy();
        console.log(obj.get('web'));
        console.log(obj.get('user'));
    }]);
    m.controller('ctrl2', ['$scope', '$cacheFactory', function ($scope, $cacheFactory) {

        var obj = $cacheFactory.get('hdphp'); //获取缓存对象
        $scope.data = obj.get('web').url;

    }]);
</script>
</body>

</html>